/**
 * The BigTwoCard class is a subclass of the Card class and is used to model a card used in a Big Two card game. It
 * should override the compareTo() method it inherits from the Card class to reflect the ordering of cards used in a Big
 * Two card game. Below is a detailed description for the BigTwoCard class.
 *
 * @author Jiang Feiyu (3035770800)
 */
public class BigTwoCard extends Card{
    /**
     * Creates an instance of BigTwoCard by calling the constructor(super) of Card class.
     *
     * @param suit
     *            an int value between 0 and 3 representing the suit of a card:
     *            <p>
     *            0 = Diamond, 1 = Club, 2 = Heart, 3 = Spade
     * @param rank
     *            an int value between 0 and 12 representing the rank of a card:
     *            <p>
     *            0 = 'A', 1 = '2', 2 = '3', ..., 8 = '9', 9 = '10', 10 = 'J', 11
     *            = 'Q', 12 = 'K'
     */
    public BigTwoCard(int suit, int rank) {
        super(suit,rank);
    }

    /**
     * a method for comparing the order of this card with the specified card. Returns a negative integer, zero, or a
     * positive integer when this card is less than, equal to, or greater than the specified card.
     *
     * @param card The card with which user wants to compare.
     */
    public int compareTo(Card card) {
        int this_rank = this.rank;
        int card_rank = card.rank;

        /**
         * Since Rank 2 is the largest and Rank A is the second, we need to put the rank A (pos:0) to the position of
         * rank 14 (pos: 13) and put the rank 2 (pos:1) to the position of rank 15 (pos: 15)
         */
        switch (this_rank) {
            case 0:
                this_rank = 13;
            case 1:
                this_rank = 14;
        }

        switch (card_rank) {
            case 0:
                card_rank = 13;
            case 1:
                card_rank = 14;
        }

        if (this_rank > card_rank) {
            return 1;
        } else if (this_rank < card_rank) {
            return -1;
        } else if (this.getSuit() > card.getSuit()) {
            return 1;
        } else if (this.getSuit() < card.getSuit()) {
            return -1;
        } else {
            return 0;
        }
    }
}
